1484242483 by Unknown
Author:Unknown
Language: eng
Format: epub
Published: 2018-11-30T20:54:33+00:00
Chapter 6 projeCtiles!
}
}
public fireWeapon() {
this.weapon.fire();
this.bulletCount = this.weapon.fireLimit - this.weapon.
shots;
}
public renderPickup(): void {
this.pickup = new Pickup(this.gameInstance, {x: 12,
y: 12});
}
}
Making it to the Big Screen
We are missing one small piece of the puzzle so far—that is, when do we render the pickup on the screen and to what frequency? To see results quickly we shall be sending the coordinates directly on the client side when we instantiate our projectile class. Let’s refresh our memories.
All of the game logic will be in the game.ts file. This means that all of the modules come together with business rules inside of one area. This makes it easy to see what the rules of the games are.
For a much bigger project it is best to exclude the implementation and avoid having everything in one giant file. This also means possibly having the class and the implementation of the game rules on the same directory but in separate files.
We shall be doing this in our final chapter when we refactor the lot. For now let’s keep it simple and implement it directly without any abstractions.
Inside of game.class.ts file we will add the code from Listing 6-5.
64
Chapter 6 projeCtiles!
Listing 6-5. src/client/game/game.class.ts
...
protected manageAssets(game): void {
this.actors = [];
this.actor = new Player(game);
// create a new instance for our projectile which will
render the pickup
// graphic as well. We went for a composition approach
const projectile = new Projectile(game);
// after the instance has been created, just add water :)
projectile.renderPickup();
...
By adding the new projectile and having control when and where it
renders, we can place a graphic illustrating the type of power pickup the player can eventually pickup. We still have a long way to go. We are missing four fundamental features at the moment.
The first missing fundamental is the player having the ability to
pickup the power. This means we should modify the player class with an assign pickup method. The second fundamental is a way to tell the game engine that the player and the pickup have overlapped with each other and to go ahead and assign the pickup to the player who was lucky enough to get ammo.
Third, we need to update our keyboard class to allow the user to fire her cannons while pressing the space bar on the keyboard. The final
fundamental is adding some sort of graphic that the player has picked up the power up. We shall solve this by implementing a HUD.
The HUD will also show the total number of ammo and the remaining
ammo if the player decides to unleash her cannons. We shall solve the first one pretty easily thanks to Phaser. Perform this operation with an overlap method that we shall call during the game loop.
65
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Twisted Games: A Forbidden Royal Bodyguard Romance by Ana Huang(3666)
Den of Vipers by K.A Knight(2567)
The Push by Ashley Audrain(2564)
Win by Harlan Coben(2512)
Echo by Seven Rue(2137)
Beautiful World, Where Are You: A Novel by Sally Rooney(2035)
Leave the World Behind by Rumaan Alam(1982)
Iron Widow by Xiran Jay Zhao(1967)
Baby Bird by Seven Rue(1939)
Midnight Mass by Sierra Simone(1899)
A Little Life: A Novel by Hanya Yanagihara(1742)
Undercover Threat by Sharon Dunn(1678)
The Four Winds by Hannah Kristin(1669)
Bridgertons 2.5: The Viscount Who Loved Me [Epilogue] by Julia Quinn(1665)
The Warrior's Princess Prize by Carol Townend(1542)
Sister Fidelma 07 - The Monk Who Vanished by Peter Tremayne(1495)
Snowflakes by Ruth Ware(1482)
Dark Deception by Rina Kent(1430)
Facing the Mountain by Daniel James Brown(1428)
